using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(menuName = "Data/State/Player/PlayerIdle", fileName = "PlayerIdle")]
public class PlayerState_Idle : PlayerState
{
    //
    public override void Enter()
    {
        base.Enter();
        PlayerControl.Instance.Stop();
    }
    
    //
    public override void Exit()
    {
        base.Exit();
    }
    
    //
    public override void LogicUpdate()
    {
        base.LogicUpdate();
        // 玩家移动 并且 鼠标状态不为 AStar寻路状态
        if (PlayerInput.Instance.GetIsInputMove && PlayerInput.Instance.MouseState != MouseState.AStar)
        {
            stateMachine.SwitchState(stateMachine.stateTable[typeof(PlayerState_Walk)]);
        }
        
        // 使用工具，并且当前鼠标状态为 使用工具或物品，并且当前人物状态为 可使用工具
        if (PlayerInput.Instance.GetIsUseTool && PlayerInput.Instance.MouseState == MouseState.UseToolOrItem && Player.Instance.GetCurrentKit() == PlayerKit.Tool)
        {
            stateMachine.SwitchState(stateMachine.stateTable[typeof(PlayerState_UseTool)]);
        }

        // 玩家受伤
        if (Player.Instance.IsHit)
        {
            stateMachine.SwitchState(stateMachine.stateTable[typeof(PlayerState_Hit)]);
        }

        // 玩家死亡
        if (Player.Instance.IsDeath)
        {
            stateMachine.SwitchState(stateMachine.stateTable[typeof(PlayerState_Death)]);
        }
    }
    
    //
    public override void PhysicalUpdate()
    {
        base.PhysicalUpdate();
    }
}